import { getYearListData } from '@/api/system/global-setting/calendar/index'
const state = {
  // 出差申请单据状态
  travelStates: [
    {
      label: '全部',
      value: ''
    },
    {
      label: '未提交',
      value: '0'
    },
    {
      label: '审批中',
      value: '1'
    },
    {
      label: '已审批',
      value: '2'
    },
    {
      label: '驳回',
      value: '3'
    },
    {
      label: '已付款',
      value: '4'
    },
    {
      label: '已生成执行单',
      value: '5'
    },
    {
      label: '报销完成',
      value: '6'
    }
  ],
  // 出差申请单状态 map
  travelStatesMap: {
    0: '未提交',
    1: '审批中',
    2: '已审批',
    3: '驳回',
    4: '已付款',
    5: '已生成执行单',
    6: '报销完成'
  },
  // 停启用列表
  listState: [
    {
      label: '全部',
      value: ''
    },
    {
      label: '启用',
      value: '0'
    },
    {
      label: '停用',
      value: '1'
    }
  ],
  // 预算年度
  budgetYearList: []
}

const mutations = {
  /**
   * 会计年度
   * @param {Array} state
   * @param {Array} payload
   * @constructor
   */
  SET_YEAR_LIST(state, payload) {
    state.budgetYearList = payload
  }
}

const actions = {
  getYearList({ commit }) {
    return getYearListData().then(res => {
      if (res.code === 20000) {
        // console.log(res)
        commit('SET_YEAR_LIST', res.data)
      }
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
